//
//  Team9ExpertFaceCollectionCell.m
//  Team9Project
//
//  Created by 朱嘉祺 on 15/10/19.
//  Copyright © 2015年 apple. All rights reserved.
//

#import "Team9ExpertFaceCollectionCell.h"
#import "Team9ExpertFootFaceCell.h"
#import "Team9ExpertLikeUserModel.h"

#import "Team9ExpertUsersVc.h"
#import "Team9workVc.h"
#import "Team9DesignerVc.h"

@interface Team9ExpertFaceCollectionCell ()<UICollectionViewDataSource, UICollectionViewDelegate>
@property(nonatomic, strong)UICollectionView *collectionView;
@end

@implementation Team9ExpertFaceCollectionCell


- (void)setArray:(NSArray<Team9ExpertLikeUserModel *> *)array
{
    if (_array != array) {
        _array = array;
        [self.collectionView reloadData];
    }
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
        layout.itemSize = CGSizeMake(40 * WIDTH / 375, 40 * WIDTH / 375);
         layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        layout.minimumInteritemSpacing = 10;
        layout.minimumLineSpacing = 10;
        self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 40 * WIDTH / 375 + 20) collectionViewLayout:layout];
        [self addSubview:_collectionView];
        self.collectionView.dataSource = self;
        self.collectionView.delegate = self;
        [_collectionView registerClass:[Team9ExpertFootFaceCell class] forCellWithReuseIdentifier:@"reuse"];
        self.collectionView.backgroundColor = [UIColor whiteColor];
        [_collectionView setContentInset:UIEdgeInsetsMake(0, 10, 0, 10)];
        self.collectionView.bounces = NO;
    }
    return self;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return self.array.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    Team9ExpertFootFaceCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse"forIndexPath:indexPath];
    cell.model = self.array[indexPath.row];
    return cell;
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(nonnull NSIndexPath *)indexPath{
//    NSLog(@"test");
    Team9ExpertLikeUserModel *model = self.array[indexPath.row];
    [Team9Tool viewContrller:self.VC pushBytype:model.author_type andId:model.author_id];
}
- (void)changecolor{
    [super changecolor];
    if ([Team9EveningType shareEvening].eveningFailling) {
        self.collectionView.backgroundColor = [UIColor colorWithWhite:0.15 alpha:1];
    } else self.collectionView.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1];
}
@end
